###################################################################
#  Tests von wheelHandler                                         #
#  Autor : Medawar                                                #
#  Clock periode : 10Khz                                          # 
###################################################################


restart -f
### Clock 10 Khz
force -freeze sim:/wheelhandler/clockinput 1 0, 0 {0.05ms} -r 0.1ms
force -freeze sim:/wheelhandler/wheelinputa 0 0
force -freeze sim:/wheelhandler/wheelinputb 0 0
force -freeze sim:/wheelhandler/busmode 00 0


run 8ms
# VERY FAST BEGIN SPEED ROTATION 
set x 0
set speed 4  
while {$x<20} {
  set speedBetween [expr $speed/10.0]
  force -freeze sim:/wheelhandler/wheelinputa 1 0
  
  run $speedBetween  ms
  force -freeze sim:/wheelhandler/wheelinputb 1 0
  run $speed ms
  force -freeze sim:/wheelhandler/wheelinputa 0 0
  run $speedBetween ms
  force -freeze sim:/wheelhandler/wheelinputb 0 0
  run $speed ms
  incr speed
  incr x
}
# Inverse rotation
set x 0
set speed 4
while {$x<10} {
  set speedBetween [expr $speed/10.0]
  force -freeze sim:/wheelhandler/wheelinputb 1 0
  run $speedBetween ms
  force -freeze sim:/wheelhandler/wheelinputa 1 0
  run $speed ms
  force -freeze sim:/wheelhandler/wheelinputb 0 0
  run $speedBetween ms
  force -freeze sim:/wheelhandler/wheelinputa 0 0
  run $speed ms
  incr speed
  incr x
}
run 100 ms
# MIDDEL FAST ROTATION
set x 0
set speed 9  
while {$x<10} {
  set speedBetween [expr $speed/10.0]
  force -freeze sim:/wheelhandler/wheelinputa 1 0
  run  $speedBetween ms
  force -freeze sim:/wheelhandler/wheelinputb 1 0
  run $speed ms
  force -freeze sim:/wheelhandler/wheelinputa 0 0
  run $speedBetween ms
  force -freeze sim:/wheelhandler/wheelinputb 0 0
  run $speed ms
  incr speed
  incr x
}

run 100 ms

# Slowly rotation
set x 0
set speed 20  
while {$x<10} {
  set speedBetween 0.$speed
  force -freeze sim:/wheelhandler/wheelinputa 1 0
  run  $speedBetween ms
  force -freeze sim:/wheelhandler/wheelinputb 1 0
  run $speed ms
  force -freeze sim:/wheelhandler/wheelinputa 0 0
  run $speedBetween ms
  force -freeze sim:/wheelhandler/wheelinputb 0 0
  run $speed ms
  incr speed
  incr x
}